#include <iostream>

using namespace std;

int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	
	long n,L,R;
	long k;
	long ans = -1;
	
	cin >> n >> L >> R;
	
	for (long i = L;i <= R;i++)
	{
		k = i;
		k %= n;
		if (k > ans)
		{
			ans = k;
		}
	}
	
	cout << ans;
	
	return 0;
}
